package com.design.softwaredesign.utils.login;

import com.design.softwaredesign.service.BackLoginService;
import com.design.softwaredesign.utils.security.AES;
import com.design.softwaredesign.vo.DataVo;
import com.design.softwaredesign.vo.TokenVo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author :WaiterXiaoYY
 * @description: TODO
 * @data :2020/11/3 16:11
 */
public class LoginUtil {

    AES aes = new AES();

    public DataVo webIsTrue(String username, String password, BackLoginService backLoginService) {
        DataVo dataVo = new DataVo();
        TokenVo tokenVo = new TokenVo();
        dataVo.setCode(202);
        dataVo.setMsg("出错辽");
        try {
            tokenVo.setToken(aes.Encrypt(username, aes.getSKey()));
            dataVo = backLoginService.authAdmin(username, password, aes.getLogintime());
            tokenVo.setUserid(username);
            List<TokenVo> tokenVoList = new ArrayList<>();
            tokenVoList.add(tokenVo);
            dataVo.setData(tokenVoList);
        } catch (Exception e) {
            e.printStackTrace();
            return dataVo;
        }
        return dataVo;
    }
}
